I am looking for a simple mandline script/program to automatically "inline" all external css and javascript references for a html file. I basically want to create a single self-contained html file suitable for sending via E-Mail. An additional bonus would be if it could also inline images as data: UIRs, but that part is not so important.
I am looking for a simple mandline script/program to automatically "inline" all external css and javascript references for a html file. I basically want to create a single self-contained html file suitable for sending via E-Mail. An additional bonus would be if it could also inline images as data: UIRs, but that part is not so important.
Share Improve this question asked Nov 27, 2009 at 13:39 SecSec 7,3526 gold badges35 silver badges58 bronze badges 3- +1 I am looking for that too. Very interested to see what turns up. – Pekka Commented Nov 27, 2009 at 13:42
- which Server-side script are you running on? – mauris Commented Nov 27, 2009 at 13:44
- PHP for me. Don't know about the TO. – Pekka Commented Nov 27, 2009 at 14:05
4 Answers
Reset to default 3EDIT : I wrote a little Python script for fun. It seems to work pretty well :
Inline2Mail
Or you can still try with :
Front piler does something like that but it implies javascript. You have an online solution as well, with premailer. Finally you have a Python and a Ruby script to do it.
There is a Node.js library which solves exactly your problem: https://github./remy/inliner/ It can be used both as a mandline script and a library.
It will make you a single .html
file which can be sent anywhere by any means and be opened later in any browser without the need in Internet connection.
If you think about inlining CSS and Javascript to make a HTML body of an email, just forget about it. Most Email clients out there will either ignore or badly damage your styles and I think all email clients will just plainly drop the inline Javascript in the body of emails.
This Python project of mine can help with getting the CSS styles inline https://github./rennat/pynliner
If it's not something that needs to be automated and you're using Windows you could open the web page in Internet Explorer and save it as 'Web Archive, single file (*.mht)'. This will pack everything into a single file, including CSS, JavaScript and images. Note that the recipients needs to have access to Internet Explorer to be able to open the Web Archive. Neither Google Chrome nor Firefox supports mht files, so it's probably a Microsoft only feature.