Does the ORDER of javascript files matter, when they are all combined into one file?

Order matters in possibly one or more of the following situations: When one of your scripts contains dependencies on another script. If the script is in the BODY and not the HEAD.. UPDATE: HEAD vs BODY doesn’t seem to make a difference. Order matters. Period. When you are running code in the global namespace that … Read more

Loading html into page element (chrome extension)

URL of a file inside an extenion folder has the following format: chrome-extension://<ID>/topbar.html You can get this path by running: chrome.extension.getURL(“topbar.html”) Now if you try to do: $(‘#topbar’).load(chrome.extension.getURL(“topbar.html”)); it wouldn’t let you because of cross-origin policy. Background pages don’t have this limitation, so you would need to load HTML there and pass result to a … Read more

Get selected text position and place an element next to it

You could position a marker span at the end of the selection, get its coordinates using jQuery, place your button at those coordinates and remove the marker span. The following should get you started: var markSelection = (function() { var markerTextChar = “\ufeff”; var markerTextCharEntity = “&#xfeff;”; var markerEl, markerId = “sel_” + new Date().getTime() … Read more

Vanilla JS event delegation – dealing with child elements of the target element

Newer browsers Newer browsers support .matches: this.container.addEventListener(‘click’, function(e){ if (e.target.matches(‘#game-again,#game-again *’)) { e.stopPropagation(); self.publish(‘primo:evento’); } }); You can get the unprefixed version with var matches = document.body.matchesSelector || document.body.webkitMatchesSelector || document.body.mozMatchesSelector || document.body.msMatchesSelector || document.body.webkitMatchesSelector And then use .apply for more browsers (Still IE9+). Older browsers Assuming you have to support older browsers, you can … Read more

Manipulate the or tag in React

It’s ok to change the lang property directly and you may do so changing the value of document.documentElement.lang For example: var newLang = ‘fr’; … document.documentElement.lang = newLang; // will set the lang property to ‘fr’

Pretty print XML in java 8

In reply to Espinosa’s comment, here is a solution when “the original xml is not already (partially) indented or contain new lines“. Background Excerpt from the article (see References below) inspiring this solution: Based on the DOM specification, whitespaces outside the tags are perfectly valid and they are properly preserved. To remove them, we can … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)