Skip to content

Instantly share code, notes, and snippets.

@devinus
Last active March 24, 2020 21:08
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save devinus/e47177f4abad5dc5e0a5aeff49baabf9 to your computer and use it in GitHub Desktop.
Save devinus/e47177f4abad5dc5e0a5aeff49baabf9 to your computer and use it in GitHub Desktop.
Rebelmail Code Challenge

Rebelmail Code Challenge

Minimize an HTML page with inline CSS using whatever novel techniques you can think of without affecting the presentation of the document.

Write a microservice to consume the HTML, save an email document to a database with the original and transformed versions of the document, and send the transformed result in an HTML email to a specified recipient.

Rules

  1. You MAY use any language.
  2. You MAY use any HTML or CSS parsing libraries.
  3. You MUST NOT use any libraries specifically designed to minimize HTML or CSS.
  4. You MUST implement at least 3 strategies.
  5. You MUST NOT use removal of comments or whitespace or any of the examples as one of the required strategies.
  6. You SHOULD NOT spend too much time on it.
  7. You SHOULD write tests.
  8. You SHOULD open source it.
  9. You SHOULD ask questions if anything is unclear.

Example

Consider the following HTML:

<!DOCTYPE html>
<html>
  <head>
    <title>Rebelmail Code Challenge</title>
    <style>
      h1 {
        font-family: monospace;
      }
    </style>
  </head>
  <body>
    <h1>Hello world</h1>
    <p><span>Lorem ipsum</span> dolor sit amet, consectetur adipisicing
    elit, sed do eiusmod tempor incididunt ut labore et dolore magna
    aliqua.</p>
    <style>
      span {
        font-family: monospace;
      }
    </style>
  </body>
</html>

One strategy may be to combine the style elements into one:

 <!DOCTYPE html>
 <html>
   <head>
     <title>Rebelmail Code Challenge</title>
     <style>
       h1 {
         font-family: monospace;
       }
+
+      span {
+        font-family: monospace;
+      }
     </style>
   </head>
   <body>
     <h1>Hello world</h1>
     <p><span>Lorem ipsum</span> dolor sit amet, consectetur adipisicing
     elit, sed do eiusmod tempor incididunt ut labore et dolore magna
     aliqua.</p>
-    <style>
-      span {
-        font-family: monospace;
-      }
-    </style>
   </body>
 </html>

Another strategy may be to then combine similar declarations into a single selector:

 <!DOCTYPE html>
 <html>
   <head>
     <title>Rebelmail Code Challenge</title>
     <style>
-      h1 {
-        font-family: monospace;
-      }
-
-      span {
+      h1, span {
         font-family: monospace;
       }
     </style>
   </head>
   <body>
     <h1>Hello world</h1>
     <p><span>Lorem ipsum</span> dolor sit amet, consectetur adipisicing
     elit, sed do eiusmod tempor incididunt ut labore et dolore magna
     aliqua.</p>
   </body>
 </html>

Good luck!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment