 					CUI.dom.remove(css_node)
 						# old_css_nodes.push(css_node)
 
-				CUI.dom.setAttribute(document.body, "data-cui-theme", opts.theme)
+				addThemeToBody()
 
 				# console.info("CSSLoader.loadTheme: Loading went fine: ", url, "Removing the old CSS node: ",  old_css_nodes)
 				CUI.Events.trigger


		dfr.always =>
			CUI.dom.removeAttribute(cssNode, "data-cui-loading")

		dfr.fail (css_href) =>
			console.error("CSSLoader: Loading failed, removing node.", css_href)


		# console.error "parsing location", url, CUI.getPathToScript(), css_href

		addThemeToBody = ->
			if not opts.theme
				return
			CUI.dom.setAttribute(document.body, "data-cui-theme", opts.theme)
			for _class in document.body.classList
				if not _class.startsWith("cui-theme")
					continue
				CUI.dom.removeClass(document.body, _class)
				break
			CUI.dom.addClass(document.body, "cui-theme-#{opts.theme}")
			return

		cssNode = CUI.dom.element "LINK",
			rel: "stylesheet"
			charset: "utf-8"
