GreenSock: Preventing Flash of Unstyled Content on Load
Master GSAP animation loading and performance optimization
Core Learning Objectives
Network Simulation
Learn to use Chrome DevTools to simulate slow network conditions and identify loading issues in real-world scenarios.
FOUC Prevention
Implement visibility controls and event listeners to prevent flash of unstyled content during GSAP library loading.
Google Ads Validation
Understand Google's HTML5 ad requirements and use their validator to ensure compliance before submission.
Ensure you have the GSAP-FOUC folder from the class files and a code editor that supports folder opening like Visual Studio Code. Disable ad blockers as they may prevent GSAP from loading properly.
Project Setup Process
Open Project Folder
Navigate to Desktop > Class Files > JavaScript Class > GSAP-FOUC and open the folder in your code editor
Launch HTML File
Open index.html in your code editor and preview it in Chrome browser for DevTools access
Verify Animation
Confirm the animated banner ad works properly and disable any ad blockers if the animation fails to load
Network Throttling Setup
Access DevTools
Right-click on the page and select Inspect, then navigate to the Performance tab
Configure Throttling
Click the gear icon to show settings and set Network throttling to Slow 3G
Record Performance
Click Record, reload the page with Cmd-R or Ctrl-R, then stop recording when animation begins
Analyze Timeline
Hover over the timeline to see screenshots and identify when text appears before disappearing and scaling up
On slow connections, users see unprepared text assets before GSAP loads and hides them for animation. This creates an unprofessional flash of unstyled content that needs to be addressed.
FOUC Prevention Implementation
Hide Initial Content
Add 'visibility: hidden' to the #banner CSS rule in main.css to hide content during loading
Wrap Animation in Function
Create an animate() function in index.html that contains the entire GSAP timeline animation code
Add Event Listener
Use window.addEventListener('load', animate) to trigger animation only after page fully loads
Reset Visibility
Add .set('#banner', {visibility:'visible'}) to the timeline before other animations to show content
With throttling enabled, users now see only the gray background during loading, followed immediately by the banner appearance and smooth animation start once everything is ready.
Google HTML5 Ad Requirements
Google Ads Compliance Checklist
GSAP and Google Fonts are excluded from this limit
Other font sources will cause rejection
Must specify exact width and height from Google's approved sizes
These cause validation errors and must be deleted
Required for Google's campaign link integration
Use h5validator.appspot.com/adwords/asset to check for issues
Always run your compressed zip file through Google's H5 validator before submission to catch compliance issues early and avoid rejection delays.
Key Takeaways


