Skip to main content
 

*One simple trick that simplifies JS Loading!*

@103532563190745371016 has delved deep into script loading and found that it's better to  just use a regular script tag to load many resources.  The key is to use the async and defer attributes.

It turns out that preload scanners work better than the gobs of script-tag-injecting js code, even on older mobile browsers.

If you're targeting IE9 and above you can also use the _onload_ attribute on your script tag to trigger execution when the script is async loaded.

Work is ongoing to update our docs and existing uses in google3.


https://docs.google.com/a/google.com/document/d/1vOKlHN3VI9nlJYbkCIXSZiP_T9QimGvaoh48qR9BKI8/edit?_e...