# What are loaders (view->makeLoader()) and why are they needed?

**URL:** https://discourse.roots.io/t/what-are-loaders-view-makeloader-and-why-are-they-needed/26992
**Category:** acorn
**Tags:** sage10, acorn, woocommerce
**Created:** 2024-04-15T13:56:53Z
**Posts:** 7

## Post 1 by @cavaquinho93 — 2024-04-15T13:56:53Z

Hi,

I have an application (Wordpress-based) running on WPEngine, a host with notoriously strict security policies that, amongst other things, prevent the web server from writing files. The known workaround for this with Sage is to pre-compile all Blade templates after each deployment. This has worked for me in the past, however in this case I am using Woocommerce via [generoi/sage-woocommerce](https://github.com/generoi/sage-woocommerce), which makes uses of “loaders”. Would somebody be able to explain why it is necessary to include a “loader”, rather than including the compiled view directly itself?

I have written a helper command to “pre-compile” these loaders too, but it doesn’t work because the id/hash in the filename seems to be different on the server so it ends up trying to rebuild them on the fly anyway.

TIA.

---

## Post 2 by @Sven_Kaptein — 2024-05-30T12:08:17Z

We have exact the same problem, also thought of the approach to build a script to pre-compile them too. But did you manage to fix it/fit the script?

---

## Post 3 by @cavaquinho93 — 2024-05-30T12:20:34Z

Sadly not. Each time I solved one problem, another arose. For various reasons, this issue being one of them, we migrated this project to another host without these limitations. Please do update me if you manage it though!

---

## Post 4 by @Sven_Kaptein — 2024-05-30T13:20:35Z

Well, we now kinda solved it by not using the wc\_get\_template function but @include functions for the templates we include in our regular views. It seems to an ok-ish solution.  
Though bypassing this function feels like we might hit some bumps further down the road.

I now created the issue on github for generoi/sage-woocommerce as well:

> <https://github.com/generoi/sage-woocommerce/issues/33>
>
> We use sage roots 10 on WP Engine with your library.
> The loader files are now c…reated in the view cache folder when the page is visited and not when wp acorn view:cache command is ran. This is an issue on WP Engine, because you need to be logged in, in order to create php files on the filesystem.
> 
> Is it possible that those loader files are created when running wp acorn view:cache? 
> 
> Also see this thread on discourse: https://discourse.roots.io/t/what-are-loaders-view-makeloader-and-why-are-they-needed/26992

---

## Post 5 by @cavaquinho93 — 2024-05-30T14:55:51Z

Ah yes, that wouldn’t work for us in our situation. Thanks for submitting the issue on Github, will keep my eye out for updates!

---

## Post 7 by @oxyc — 2024-06-15T21:38:18Z

I published [GitHub - generoi/sage-cacheable-viewloaders](https://github.com/generoi/sage-cacheable-viewloaders) which should make the view loaders cacheable, haven’t really tried it much so open up an issue if it doesn’t work.
