Watch the video for which tasks to automate
Last active
April 5, 2019 06:25
-
-
Save deadcoder0904/fe5fc34dd2c5877d46672f43b33d1b18 to your computer and use it in GitHub Desktop.
Automate boring tasks with DOM Testing Library by Kent C Dodds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loadScript(filePath) { | |
// Create a script tag, set its source | |
var scriptTag = document.createElement("script"); | |
// And listen to it | |
scriptTag.onload = function(loadEvent) { | |
// This function is an event handler of the script tag | |
console.log('The file has been loaded. Do something else.'); | |
} | |
// Make sure this file actually loads instead of a cached version | |
// Add a timestamp onto the URL (i.e. file.js?bust=12345678) | |
var cacheBuster = ""; | |
cacheBuster = "?bust=" + new Date().getTime(); | |
// Set the type of file and where it can be found | |
scriptTag.type = "text/javascript"; | |
scriptTag.src = filePath + cacheBuster; | |
// Finally add it to the <head> | |
document.getElementsByTagName("head")[0].appendChild(scriptTag); | |
} | |
window.loadScript = loadScript; | |
// USAGE 👇 | |
// loadScript('https://unpkg.com/[email protected]/dist/dom-testing-library.umd.js') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment