1 min read

Tags

I was wondering about integrating JavaScript into my Software Design blog and Markdown clearly didn’t support HTML… at least that was what I thought. I still made Jekyll import my JavaScript code on my request.

1
2
3
4
5
6
7
8
9
10
11
12

There are several ways to include JavaScript on demand using Jekyll.

  1. RAW HTML which looked messy but it does work
  2. Modify the header code generated by Jekyll to import JavaScript into the Post
  3. Modify the header code generated by Jekyll to use a script element

I rejected option 1, though I may use it one day, because it is just messy. Everything must be tightly aligned on the left of the text which is okay for something short but terrible for longer scripts.

I rejected option 2 because I seem to prefer having my javascript loaded remotely rather than having it embedded into my page. In the end it isn’t much different than option 3.

I took the option of having Jekyll generate a separate script element to import multiple scripts from a remote location. I just add a tag at the top of the post and my script is loaded and ready to run.