Skip to content
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

Merged
merged 4 commits into from
Nov 30, 2013
Merged

Speedier jQuery and Twitter widgets.js #11369

merged 4 commits into from
Nov 30, 2013

Conversation

ssorallen
Copy link
Contributor

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.

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>
Copy link
Collaborator

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://

Copy link
Contributor Author

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

Copy link
Collaborator

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.

Copy link
Contributor Author

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.
@maxwellium
Copy link
Contributor

+1

@cvrebert
Copy link
Collaborator

/cc @mdo

mdo added a commit that referenced this pull request Nov 30, 2013
Speedier jQuery and Twitter widgets.js
@mdo mdo merged commit a15a6df into twbs:master Nov 30, 2013
@mdo mdo mentioned this pull request Nov 30, 2013
@mdo
Copy link
Member

mdo commented Nov 30, 2013

<3

@ssorallen ssorallen deleted the speedier-js-loading branch November 30, 2013 18:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants