SyntaxStudy
Sign Up
jQuery Beginner 3 min read

Async Loading jQuery

Loading jQuery Efficiently

Load jQuery asynchronously from a CDN with a local fallback. Use SRI integrity attributes for security.

Example
<!-- Async load with fallback -->
<script async src="https://code.jquery.com/jquery-3.7.1.min.js"
  integrity="sha384-..." crossorigin="anonymous"
  onload="window.jQuery || document.write('<script src=\"/js/jquery.min.js\"></s' + 'cript>')">
</script>
<!-- Defer to avoid render-blocking -->
<script defer src="/js/jquery.min.js"></script>
<script defer src="/js/app.js"></script>
<!-- Never block render with synchronous script in <head> -->
Pro Tip

defer keeps script order guaranteed unlike async — use defer for scripts that depend on each other.