Skip to content

Instantly share code, notes, and snippets.

@kribblo
Created August 24, 2016 15:38
Show Gist options
  • Save kribblo/29f964d8482b10e21541598a37afbc28 to your computer and use it in GitHub Desktop.
Save kribblo/29f964d8482b10e21541598a37afbc28 to your computer and use it in GitHub Desktop.
Export base URL of current file, for use in dynamic loading etc. Runs once, at load-time.
'use strict';
const scripts = document.getElementsByTagName('script');
const currentScript = scripts[scripts.length - 1];
const baseURL = currentScript.src.substring(0, currentScript.lastIndexOf('/'));
module.exports = baseURL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment