instantpage / instant.page

Make your site’s pages instant in 1 minute and improve your conversion rate by 1%
https://instant.page
MIT License
6.04k stars 205 forks source link

Provides minified script #22

Closed ibrokemycomputer closed 5 years ago

ibrokemycomputer commented 5 years ago

This provides a simple minified script to squeeze a little extra performance. I want to submit another PR that includes Babel for ES5 support + minification as a build step if that is something you are interested in? Essentially it would add a couple npm dependencies for you to use before publishing (or automatically run as a a build step/git hook) that would generate a instantpage.min.js file for xbrowser use. Let me know before I spend the time! As all of us devs know, time is precious :smile:

ibrokemycomputer commented 5 years ago

For this, minification was done @ https://jscompress.com/ with the "ECMAScript 2019 (via babel-minify)" box checked. Everyone has their own preference, but you should consider using semicolons as compilers sometimes have issues with missing semicolons. I have to have IE11 support for agency clients, so we tend to use Babel often so we don't have to write 'old' ES5 code

s0kil commented 5 years ago

You can also use jsDelivr which automatically minifies and caches the file: https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js

ibrokemycomputer commented 5 years ago

You can also use jsDelivr which automatically minifies and caches the file: https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js

I cant believe I hadnt heard of this yet, thank you for sharing! I think ES5 support would help this become more popular, however as a dev I hate continuing support for IE11 and just want it to go away lol.

ibrokemycomputer commented 5 years ago

Nice. I knew about the classic "packer" but hadn't heard of Google's version. Thank you for sharing yet again! I updated the script in the PR.

dieulot commented 5 years ago

There’s actually no performance to be gained from minification because instant.page fits in a single TCP packet (under ~1.4kB).

I’m not interested in making it compatible with ES5. I like the current discrimination for browsers that don’t support modules because the user-optimized way to add instant.page is by using the CDN, and browsers that understand modules for the most part also understand subresource integrity, which is great for security.

The only current browser with a lot of usage that doesn’t understand modules is UC Browser, but they’re developing a new version that does. I’m hopeful it will come out this year.

Thanks anyway.