Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dom-element-loader

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dom-element-loader

The simpliest way to load your HTML as DOM element for Webpack 4+.

  • 1.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
5
increased by150%
Maintainers
1
Weekly downloads
 
Created
Source

dom-element-loader

The simpliest way to load your HTML as DOM element/node for Webpack 4+.

Usage

import ui from './templates/ui.html' // ui will be a dom Node 

ui.style.background = '#FFF' // do whatever you want on it ^_^

document.appendChild( ui )
<div class='sexy'>this div gonna be import in your js as DOM element</div>

Installation

npm install --save dom-element-loader
module.exports = {
	//..
    module: {
		//..
        loaders: [
            { test: /\.(html)?$/, loader: 'dom-element-loader' }
        ]
    }
};

How it works internaly & why ?

Its the raw-loader using this extraStep :

const domParser = document.createElement('div')
const string2dom = (string)=>{
	domParser.innerHTML = string 
	return domParser.firstChild
}

I used this snippet a lot while developping ui for modular tools and decided to make a loader for a better life.

Other html & dom loaders :

  • html-loader : very complete but export string and not a DOM node, so its a different usage
  • dom-loader : create an extra container & doesnt work on latest webpack

Happy coding!

For more stuffs follow me on @makio64

Cheers!

License

MIT (http://www.opensource.org/licenses/mit-license.php)

Keywords

FAQs

Package last updated on 16 May 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc