Friday, August 15, 2014

Can we make web apps less reliant on network?

So I was thinking a little about how I was using bootstrap for some of my sites, and with it being a pretty commonly used code across sites it got me thinking.

Could we somehow share these resources across domains reducing the need to download, which causes us to slow things down normally.

Here is my thought.

When parsing a .html file you come across a script tag with a src a la

script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.6/angular.min.js"

When it downloads the file it (maybe?) puts it in memory so it can be used (I could be wrong here).

What I was thinking is that we maybe generate a key value store, and it does something like this:

{"https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.6/angular.min.js", "pointer to memory that this resides"}

Now instead of simply downloading a .js file, it looks at the lookup (or hash table) and finds that that EXACT path file exists in memory and just uses that instead of downloading the file again.

Caveats.

1. I don't know if it would be possible to modify that memory.
2. I wouldn't expect this caching to be indefinite, but should be do-able across pages during an active session.

As long as the downloaded data isn't capable of being modified in memory, then doing a string lookup in a local hash *should* give us a decent startup decrease because we don't need to re-download the file(s) and I can't see how we would have any problems with safety/security since you're literally using the exact same file as you downloaded earlier, you just don't need to re-download.

I'm sure I'm missing something here, but I would think that this should be possible. Got any ideas? hit me up on twitter (@onaclov2000) or leave a comment here

Wednesday, August 6, 2014

Movies Oh My

I've been a busy boy.

In my quest to generate a boatload of Angular Services (for angularjsservices.com, dont hate the site it is terrible, if you want to help build it let me know!).

I wrote up another library but this time for my movies.

https://github.com/onaclovtech/movielibrary

The cool thing here is I built a rottentomatoes.js angular service for it.

https://github.com/onaclovtech/rottentomatoes

I got it all nice looking and then discovered omdbapi and guess what? now we have one for that too.

https://github.com/onaclovtech/omdbapi

You can substitute them and get your data.

Now the bad news. (but potentially good news).

The JSON returned is different between the two. So something I'm thinking about that would be really slick is if we could essentially take the format from each and push the data to a title,picture,etc variables, then we simply return our search and it contains an object with the appropriate fields in a standard location. I think this would be huge for ALL of my Angular Services to basically build a JSON format that will be consistent, and the service will manage converting.

If you're interested in helping out with coming up with standards for this I would love it. If you're interested in helping build angularjsservices to what it SHOULD be, I would love that.

In the mean time I'm building building building.

Join me and build an angular service too? (trust me they're surprisingly easy, and they make using angular even more fun)

I'm using Firebase to store off the data just like my book library. Firebase sure is handy.

While playing with this I realized something....I can control my roku with a webpage and I don't need chrome's special stuff (that the chromecast is using) I can just use a local nodejs server and firebase and host my site anywhere. I will be working on that next. Can you figure out how to do it? I think I've given some good hints :)