Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should code be minimized #1502

Open
mcmcclur opened this issue Jul 8, 2024 · 5 comments
Open

Should code be minimized #1502

mcmcclur opened this issue Jul 8, 2024 · 5 comments
Labels
enhancement New feature or request

Comments

@mcmcclur
Copy link

mcmcclur commented Jul 8, 2024

I notice that comments, either in code or in markdown of a Framework project, are preserved in the output that appears in dist after build. Thus, if my index.md file looks like so:

# My lovely work project
This is an important project

<!-- Man, I cannot STAND my boss!!! -->

## Section 1

Then I might lose my job. :(

So, should comments be sanitized in a build?

@mcmcclur mcmcclur added the enhancement New feature or request label Jul 8, 2024
@Fil
Copy link
Contributor

Fil commented Jul 8, 2024

You should definitely sanitize this comment if your boss can view source, but IMO it is not framework's business to do so. If you write a post-processor that strips comments, make sure to keep Framework's own comments, which are used as anchors for dynamic “cells” (e.g. <!--:55cc50bc:-->).

@mcmcclur
Copy link
Author

mcmcclur commented Jul 8, 2024

Hi Fil, thanks!

I guess I was surprised to see the comments in production code for efficiency purposes, rather than for privacy. That is, it seems to be standard practice to not only clean comments but to also minimize and bundle production code to reduce transfer time and provide a snappier user experience.

I'm sorry if I wasn't clear on the motivation for the question.

@mcmcclur mcmcclur closed this as completed Jul 8, 2024
@Fil
Copy link
Contributor

Fil commented Jul 8, 2024

Framework bundles and the css and js files coming from npm and node modules, but leaves the code blocks and HTML intact in the pages and js imports (edited). I can see how it could be useful to minimize those too on build. Maybe do not close this issue, but retitle it :)

@mcmcclur mcmcclur reopened this Jul 8, 2024
@mcmcclur mcmcclur changed the title Should comments be sanitized Jul 8, 2024
@mcmcclur
Copy link
Author

mcmcclur commented Jul 8, 2024

Framework bundles and minifies its css and js files, but leaves the code blocks and HTML intact

That does not seem to be the case. Certainly, the code that it links from jsDelivr is minimized but, as far as I can tell, Javascript files written by the app author are not. For example:

https://mcmcclur.observablehq.cloud/framework-for-math/_import/common_components/build_samples.11ccf515.js


I did reopen and retitle the project.

@Fil
Copy link
Contributor

Fil commented Jul 8, 2024

Ah you're right—currently only the npm/node modules are minified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
2 participants