<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="227546" data-post-id="227546">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="mitnik" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mitnik/120/24266_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  mitnik
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>i tried the approach and unfortunately the scripts are bundled inside the app.js</p>
<p>from 57K initially, after refactoring - implementing this approach of loading few js components (and after digest) the app.js.gz skyrocketed to 507K</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="227546" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/page-specific-javascript-with-liveview-and-esbuild-phoenix-1-6-0/42359/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-227546" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="227546"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="227585" data-post-id="227585">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="mitnik" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/mitnik/120/24266_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  mitnik
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>finally solved it</p>
<p>non of the above will work if you don’t do the following:</p>
<p>from esbuild</p>
<blockquote>
<p>Note that when code splitting is disabled (i.e. the default behavior), an <code>import('path')</code> expression behaves similar to <code>Promise.resolve(require('path'))</code> and still bundles the imported file into the entry point bundle. No additional chunks are generated in this case.</p>
</blockquote>
<p>so you must first configure the esbuild inside config.exs like so:</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">~w(js/app.js css/quill.css --chunk-names=chunks/[name]-[hash] --bundle --outdir=../priv/static/assets --splitting --format=esm --target=es2016),
</code></pre>
<p>then in your template you must change the app.js type like so (type=“module” otherwise you will get errors that you can’t use imports outside a module …):</p>
<pre data-code-wrap="elixir"><code class="lang-elixir">&lt;script defer phx-track-static type="module" src={Routes.static_path(@conn, "/assets/js/app.js")}&gt;&lt;/script&gt;
</code></pre>
<p>now the code will load from the generated chunks<br>
<img src="https://forum.elixirforum.com/uploads/default/original/3X/e/c/eccb32c7a6d94a49803224055250ddde55a84bbd.png" alt="image" data-base62-sha1="xMM24MvKypln911G7ZqkgDAz0ip" width="398" height="50"><br>
<img src="https://forum.elixirforum.com/uploads/default/original/3X/9/4/94f6bb49ec6744cf831a5e8ca405b81a6c9873a9.png" alt="image" data-base62-sha1="lfNhHYHbPuFvJKLiWQOqtBdAHYB" width="472" height="46"><br>
</p><div class="lightbox-wrapper"><a class="lightbox" href="https://forum.elixirforum.com/uploads/default/original/3X/0/c/0c42d445bc6ae6779eb216cc4df223a43f8c7d1e.png" data-download-href="https://forum.elixirforum.com/uploads/default/0c42d445bc6ae6779eb216cc4df223a43f8c7d1e" title="image" rel="nofollow"><img src="https://forum.elixirforum.com/uploads/default/optimized/3X/0/c/0c42d445bc6ae6779eb216cc4df223a43f8c7d1e_2_690x431.png" alt="image" data-base62-sha1="1KsUs32PacbkTqyWZn9NrFRTcWG" width="690" height="431" srcset="https://forum.elixirforum.com/uploads/default/optimized/3X/0/c/0c42d445bc6ae6779eb216cc4df223a43f8c7d1e_2_690x431.png, https://forum.elixirforum.com/uploads/default/original/3X/0/c/0c42d445bc6ae6779eb216cc4df223a43f8c7d1e.png 1.5x, https://forum.elixirforum.com/uploads/default/original/3X/0/c/0c42d445bc6ae6779eb216cc4df223a43f8c7d1e.png 2x" data-dominant-color="2D2D2E"><div class="meta"><svg class="fa d-icon d-icon-far-image svg-icon" aria-hidden="true"><use href="#far-image"></use></svg><span class="filename">image</span><span class="informations">940×588 57.7 KB</span><svg class="fa d-icon d-icon-discourse-expand svg-icon" aria-hidden="true"><use href="#discourse-expand"></use></svg></div></a></div><p></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="227585" data-batch-url="/posts/batch_likers">
                        9
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/page-specific-javascript-with-liveview-and-esbuild-phoenix-1-6-0/42359/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-227585" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="227585"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-solved cat-solved" title="Marked as solution"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>