Javascript Rookie Question: Define Variables Inline

Posted by Dylan Kinnett on Programmers See other posts from Programmers or by Dylan Kinnett
Published on 2014-06-10T15:20:22Z Indexed on 2014/06/10 15:39 UTC
Read the original article Hit count: 306

Filed under:
|

I'm proficient with HTML and CSS but I'm still pretty shaky when it comes to Javascript. That said, I've been able to build a site using the Internet Archive Book Reader, which relies on reader.js

Here's a copy of one of my versions of reader.js https://gist.github.com/dylan-k/ed4efed2384e221d46cc

It's a good site, but I find I have to repeat things a lot. Basically, I have one copy of reader.js for every page/book featured on the site. It seems there must be a better way. I re-use the script, making copies, just so that I can change lines 28, 80, 83, 84.

Is there a way I could include just one copy of reader.js and then use a <script> tag to define these 4 lines for the individual pages?

© Programmers or respective owner

Related posts about web-development

Related posts about JavaScript