Limitations and Caveats

Before we continue, here are a few important things to note:

  • The techniques in this chapter are not compatible with scripts that are inlined (defined directly in your page’s markup). Inlining should be avoided when possible. If you must inline a script, don’t try to use the defer or async attribute on it.

  • When using any of the techniques in this chapter, you should not use document.write. Its behavior in asynchronously loaded scripts is unpredictable. If you don’t know what document.write is, then good. Suffice to say it’s the GOTO of DOM manipulation.

  • This is not a definitive guide. I’ve neglected some important platform-specific details for the sake of brevity. For example, certain mobile browsers will refuse to cache scripts larger than a certain size. So, if you’re targeting those devices, it’s important to keep scripts small.

Page load optimization is a rich subject on which whole books have been written, and script loading is just one factor. But for script-heavy sites that aren’t taking advantage of async loading, there’s plenty of low-hanging fruit to be picked using the techniques in this chapter.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.20.148