Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Pagespeed libraries #533

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 23 additions & 0 deletions README.md
Expand Up @@ -101,6 +101,29 @@ X-Page-Speed: 1.6.29.5-...
Looking at the source of a few pages you should see various changes, such as
urls being replaced with new ones like `yellow.css.pagespeed.ce.lzJ8VcVi1l.css`.

### Use Google Hosted JS (Canonicalize Javascript Libraries)

This is handy when you want to allow some of the more common javascript files to load from Google's servers.
See here: https://developers.google.com/speed/pagespeed/module/filter-canonicalize-js

To make this work with Nginx Pagespeed. Do the following on your web server.

```bash
bash scripts/pagespeed_libraries_generator.sh > ~/pagespeed_libraries.conf
sudo cp ~/pagespeed_libraries.conf /etc/nginx/
```

In the Nginx.conf file above, right after you say pagespeed on; add this
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pagespeed on; -> pagespeed on;

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what you're asking/saying here :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I just meant that I wanted "pagespeed on" to be surrounded in backticks so it would show up monospaced and look like a command. But I did this when I merged it, so no worries.


```nginx
include pagespeed_libraries.conf;
pagespeed EnableFilters canonicalize_javascript_libraries;
```

Now most of your common JS files will load from //ajax.googleapis.com/...



For complete documentation, see [Using
PageSpeed](https://developers.google.com/speed/pagespeed/module/using).

Expand Down
10 changes: 10 additions & 0 deletions scripts/pagespeed_libraries_generator.sh
@@ -0,0 +1,10 @@
#!/bin/bash
# Inspired by https://github.com/pagespeed/ngx_pagespeed/issues/532
# run this file and direct output to a file , include said file and be sure to
# enable canonicalize_javascript_libraries filter.

curl -s https://modpagespeed.googlecode.com/svn/trunk/src/net/instaweb/genfiles/conf/pagespeed_libraries.conf \
| grep ModPagespeedLibrary \
| while read library size hash url ; do
echo " pagespeed Library $size $hash $url;"
done