Loading jQuery Efficiently
Load jQuery asynchronously from a CDN with a local fallback. Use SRI integrity attributes for security.
Load jQuery asynchronously from a CDN with a local fallback. Use SRI integrity attributes for security.
<!-- 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> -->
defer keeps script order guaranteed unlike async — use defer for scripts that depend on each other.