ImageBlocker.js is a lightweight, open-source JavaScript library designed to block external images in HTML5 emails, enhancing security by preventing unauthorized content from rendering. It ensures only trusted domains are allowed for image and background image sources.
- Blocks images (
<img>tags) from untrusted domains. - Neutralizes background images defined in inline styles.
- Simple configuration with a customizable
allowedDomainsarray. - Lightweight and optimized for HTML5 email environments.
- Clone the repository:
git clone https://github.com/email5/imageblocker.git
- Navigate to the project directory:
cd imageblocker
To include ImageBlocker.js in your HTML email or project:
-
Add the following
<script>tag to your email setup:<script src="src/ImageBlocker.js"></script>
-
Customize the list of trusted domains by editing the
allowedDomainsarray in the script:const allowedDomains = ["trustedcdn.com", "secure-site.org"];
- Image Blocking: All
<img>tags withsrcattributes pointing to untrusted domains are blocked and hidden from the email content. - Background Image Removal: Inline styles containing untrusted
background-imageURLs are neutralized. - Customizable: Easily define your list of trusted domains to fit your security requirements.
Contributions are welcome! To contribute:
- Fork the repository.
- Create a new branch.
- Submit a pull request with your changes.
This project is licensed under the MIT License.