-
-
Notifications
You must be signed in to change notification settings - Fork 79k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Speedier jQuery and Twitter widgets.js #11369
Conversation
jQuery.com uses Google Analytics and so sets a cookie when you visit the site. When you request jquery.js from its CDN, code.jquery.com, you take a hit from sending your previous GA cookie in the request. Google Hosted Libraries[1] and googleapis.com never set cookies. [1] https://developers.google.com/speed/libraries/devguide
Twitter's widget library[1] provides an async snippet to inject the script tag later. Since widgets.js came before the local JS, if twitter.com took long to respond it would prevent subsequent synchronous script tags. [1] https://dev.twitter.com/docs/tfw-javascript
@@ -1,10 +1,9 @@ | |||
<!-- Bootstrap core JavaScript | |||
================================================== --> | |||
<!-- Placed at the end of the document so the pages load faster --> | |||
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script> | |||
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should remain explicitly HTTPS so that the docs work when viewed via file://
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The README says to run the docs with Jekyll, which means you'll always have
a server?
Fair enough though, I can see the benefit of opening the docs as files.
I would probably choose http instead of https though since the site is all
public. It will save SSL overhead.
On Monday, November 4, 2013, Chris Rebert wrote:
In _includes/footer.html:
@@ -1,10 +1,9 @@
-<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
+<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>This should remain explicitly HTTPS so that the docs work when viewed via
file://—
Reply to this email directly or view it on GitHubhttps://github.com//pull/11369/files#r7424412
.
Ross Allen
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The README says to run the docs with Jekyll, which means you'll always have
a server?
Yes, but people don't always follow instructions exactly or use things as intended. :-)
It's also for consistency with the our examples, which we very much want to work when opened as files. And we want things to be easily copy-pasteable and "just work". HTTPS seems to currently be the best option in light of these goals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool, I like it. I'll add the HTTPS.
URLs without protocols get "file:" prepended when their document is loaded as a file. Make sure the docs can always be opened by specifying a protocol.
+1 |
/cc @mdo |
Speedier jQuery and Twitter widgets.js
<3 |
jquery.com uses Google Analytics and so sets a cookie when you visit
the site. When you request jquery.js from its CDN, code.jquery.com,
you take a hit from sending your previous GA cookie in the request.
Google's CDN, googleapis.com, never set cookies and so doesn't add
overhead. It also is faster in my unscientific testing of a billion
Command + Shift + R's.
Twitter's widget library has an async snippet to load the JS rather
than a synchronous script tag. widgets.js was before other, important JS
and slowed down document ready occasionally even on a decent connection.