Skip to content

Instantly share code, notes, and snippets.

View aapoalas's full-sized avatar

Aapo Alasuutari aapoalas

  • Valmet Automation Inc.
  • Tampere, Finland
View GitHub Profile
@aapoalas
aapoalas / importViaScript.mjs
Last active August 24, 2019 03:38
ECMAScript dynamic import without CSP violation errors
export default url => new Promise((res, rej) => {
const script = document.createElement("script");
script.src = url;
script.type = "module";
const onload = () => {
script.remove();
res(import(url));
};
const onerror = error => {
script.remove();
@aapoalas
aapoalas / Reparentable.jsx
Last active July 9, 2018 20:06
React Component supporting reparenting through a manual DOM hack. Presume MIT licence.
define([
"react",
"react-dom",
"prop-types"
], function(
React,
ReactDOM,
PropTypes
) {
"use strict";