Skip to content

Instantly share code, notes, and snippets.

@beerendlauwers beerendlauwers/test.js
Last active Sep 30, 2015

Embed
What would you like to do?
Attempt at loading extra CSS in StackEdit without replacing default.css
// This doesn't seem to work. The browser only noticed the CSS file if it completely replaced <link type="text/css" rel="stylesheet" href="res-min/themes/default.css">.
// So, in a worst-case scenario, you can just copy that CSS file, add your changes to it, host it on Github and do the replacement with a UserCustom extension (https://github.com/benweet/stackedit/wiki/UserCustom-extensions).
// Also tried onReady https://github.com/benweet/stackedit/wiki/userCustom.onReady
$(document).ready( function() {
var loadCSS = function(href) {
var cssLink = $("<link rel='stylesheet' type='text/css' href='"+href+"'>");
$("head").append(cssLink);
};
var path = "url/to/css";
loadCSS(path);
alert("loaded");
} );
// This code might also be useful if you want to target the current StackEdit theme <link>.
$("link").filter( function(elem) {
var isStylesheet = $(this).attr("rel") === "stylesheet";
var isDefaultCss = $(this).attr("href").indexOf("res-min/themes/") === 0;
return isStylesheet && isDefaultCss;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.