Miserlou / Glance-Bookmarklet

A Speed Reading Bookmarklet
https://gun.io/blog/openspritz-a-free-speed-reading-bookmarklet
MIT License
1.56k stars 249 forks source link

Rawgithub Replacement #13

Open Miserlou opened 10 years ago

Miserlou commented 10 years ago

OpenSpritz currently serves with RawGithub - which is a terrible idea and won't scale.

We need a better solution which allows us to either stable releases, or a way to have rolling releases that track the GitHub head but don't rely on a cache service which threatens to replace our script with evil.js.

niroyb commented 10 years ago

rawgithub mentions we could use http://pages.github.com/

niroyb commented 10 years ago

Or how about making it a browser extension!

Miserlou commented 10 years ago

Pages is probably a good idea.

So is browser extension, but maybe open another ticket about that. I'd like that because then you could launch it with just a key command.

niroyb commented 10 years ago

The browser extension also means the files would be stored locally and loaded instantly.

On Mon, Mar 3, 2014 at 3:18 AM, Rich Jones notifications@github.com wrote:

Pages is probably a good idea.

So is browser extension, but maybe open another ticket about that. I'd like that because then you could launch it with just a key command.

Reply to this email directly or view it on GitHubhttps://github.com/Miserlou/OpenSpritz/issues/13#issuecomment-36489113 .

universemaster commented 10 years ago

But a browser extension would mean we'd lost the ability for it to work on iOS.

On 3 Mar 2014, at 08:20, Nick R notifications@github.com wrote:

The browser extension also means the files would be stored locally and loaded instantly.

On Mon, Mar 3, 2014 at 3:18 AM, Rich Jones notifications@github.com wrote:

Pages is probably a good idea.

So is browser extension, but maybe open another ticket about that. I'd like that because then you could launch it with just a key command.

Reply to this email directly or view it on GitHub< https://github.com/Miserlou/OpenSpritz/issues/13#issuecomment-36489113> .

Reply to this email directly or view it on GitHubhttps://github.com/Miserlou/OpenSpritz/issues/13#issuecomment-36489219 .

niroyb commented 10 years ago

Good point.

On Mon, Mar 3, 2014 at 3:21 AM, universemaster notifications@github.comwrote:

But a browser extension would mean we'd lost the ability for it to work on iOS.

On 3 Mar 2014, at 08:20, Nick R notifications@github.com wrote:

The browser extension also means the files would be stored locally and loaded instantly.

On Mon, Mar 3, 2014 at 3:18 AM, Rich Jones notifications@github.com wrote:

Pages is probably a good idea.

So is browser extension, but maybe open another ticket about that. I'd like that because then you could launch it with just a key command.

Reply to this email directly or view it on GitHub< https://github.com/Miserlou/OpenSpritz/issues/13#issuecomment-36489113> .

Reply to this email directly or view it on GitHub< https://github.com/Miserlou/OpenSpritz/issues/13#issuecomment-36489219>

.

Reply to this email directly or view it on GitHubhttps://github.com/Miserlou/OpenSpritz/issues/13#issuecomment-36489316 .

Zegnat commented 10 years ago

GitHub Pages should work, it was originally confirmed to be OK to use as CDN so serving up a single bookmarklet JS file should be no problem. (source)

Miserlou commented 10 years ago

Okay, so GitHub pages works for the JavaScript, but not for the .html which spritz.js calls.

Bummer! Any ideas?

tomByrer commented 10 years ago

Any ideas?

https://github.com/jsdelivr/jsdelivr CDN Like CDNJS, but it is like 3 CDNs multiplexed into 1 (2 big ones, several minor ones). You can also use version aliasing so minor SemVer changes can still use the same bookmarks.

rawgithub.com is cool for jsPerf, CodePen, & alpha test versions. Not so sure if he would be crazy about continuous 10s of thousands of serves per day.

Zegnat commented 10 years ago

Bummer! Any ideas?

Merge the HTML into the JS? What is the reason for keeping them separated?

tomByrer commented 10 years ago

What is the reason for keeping them separated?

You can't run a HTML bookmarklet ;) But the JS could be small to just be inserting the HTML into the DOM, if XSS allows HTML JS to be ran. Though you are onto something; the CSS could be inserted into the HTML That would cut the rawgithub.com requests significantly.

Zegnat commented 10 years ago

@tomByrer, sorry, but I don’t think I know what you mean by “a HTML bookmarklet”.

Currently the bookmarklet simply loads the spritz.js from GitHub Pages. And then spritz.js loads spritz.html via rawgithub.com. Right? So why not take the content of spritz.html and pack it inside spritz.js as a string? Then there is no need for this extra file fetching and everything can be served as a single JavaScript file through GitHub Pages.

So that’s where my question was coming from: why does it need a separate HTML file and can’t the HTML be embedded inside the JavaScript file?

tomByrer commented 10 years ago

Yes, the bookmarklet needs to be JS. I've inserted other JS via bookmarket, but never ran JS inside an inserted HTML. Have you done this?

elicwhite commented 10 years ago

We could totally put the HTML and CSS as a string inside of the javascript, the downside is that it just more difficult to maintain and introduce typos. But it would also speed things up as we wouldn't be making multiple requests. It kind of depends on what the purpose is of this. Is the end goal to be a bookmarklet, a browser extension, or just a library for splitting and displaying words that something else embeds?

Miserlou commented 10 years ago

This is a bookmarklet. If somebody wants to create a browser extension, that should be maintained as a separate project as I don't have the resources to maintain both in the same project - I'm barely keeping up with the pull requests as it is! (Also, I'm a Firefox user. Moz4lyfe.)

I vastly value code readability and maintainability more than efficiency (a single request is no big whoop) - and a having to maintain a huge string of HTML is a huge pain in the ass.

tomByrer commented 10 years ago

Maintainability is a great point; perhaps a package manager that compiles all the JS, HTML, CSS into a single JS file would be best? Then you just develop separate files, & let the compiler script combine & minify.

Miserlou commented 10 years ago

That's probably the right way to do it, have a -release and a -dev channel.

tomByrer commented 10 years ago

It is common for GitHub repos use a "build script" to collate, code check, test, minify, etc before "publishing" the final version(s) into another folder. Package manager tools can sometimes act as this build script.

Also, using a package manager should fix the Not using the global namespace issue.

tomByrer commented 10 years ago

I can throw it up on jsDelivr if you want once you get more stable & minified; should improve loading speed also. rawgithub.com is great for the dev-branch (that's why it's there), but not so hot for popular live code that has 1030+ stars :)

I'd like to see some optimizations be tested & minification landed before going on the CDN please.

tomByrer commented 10 years ago

I've suggested jsDelivr before, but they need minified files, & that has not been engineered yet. On Mar 19, 2014 12:27 PM, "Bernhard Millauer" notifications@github.com wrote:

What about using jsDelivr?

https://hacks.mozilla.org/2014/03/jsdelivr-the-advanced-open-source-public-cdn/

Reply to this email directly or view it on GitHubhttps://github.com/Miserlou/OpenSpritz/issues/13#issuecomment-38088733 .