With reference to your question 'optimal way to remove unwanted js and css files from page', hope this approach works ::

1) Include your js &amp; css files only under appropriate hook as per applicable

2) Use syntax like - 

drupal_add_js (drupal_get_path ('module', 'module_name') . '/js/js_file_name.js' 
);
   drupal_add_css(drupal_get_path('module', 'module_name') . '/css/css_file_name.css');

3) You can make use of syntax like this to set some settings variable &amp; check in your js file before invoking your event inside the behavior

In module file ::

drupal_add_js (array ('module_name' => array ('variable_name' => some_value)), 'setting' );

In js file ::


   Drupal.behaviors.testName = {
     attach: function (context, settings) {
       if(typeof Drupal.settings.module_name != 'undefined' 
    && 
    Drupal.settings.module_name.variable_name == some_value){
      // Do SOMETHING
       }
     }
  };


4) If your code already included js &amp; css files at places which could be done a better way, then you need to make the code changes accordingly. For example,

If we could include the js &amp; css files in hook_node_view (based on D7 standard, say), then we should not include it from hook_init.

Hope it helps

optimal way to remove unwanted js and css files from page

  Let $Y_1$, $Y_2$, . . . , $Y_n$ denote a random sample from the probability density function
  $$f (y | θ)=\begin{cases} (θ + 1)y^θ, &amp;  0 &lt; y &lt; 1; θ &gt; −1,\\ 0 ,&amp; \text{elsewhere.}\end{cases}$$ 
  Find the MLE  for $θ$.


My approach is first
$$L(\theta) = (\theta+1)^n \biggl(\prod_{i=1}^n y_i\biggr)^{\!\theta}$$
$$\ln L(\theta) = n \ln (\theta+1) + \theta \sum_{i=1}^n  \ln y_i$$

Taking the derivative of it, we got $$\frac{d \ln L(\theta)}{d \theta} = n\frac{1}{\theta+1} + \sum_{i=1}^n \ln y_i$$

Setting it to zero, we got $$\frac{n}{\theta+1} = - \sum_{i=1}^n \ln y_i $$

Then $$\hat{\theta} = \frac{-n}{\sum_{i=1}^n \ln y_i} - 1$$

However, the answer is $$\hat{\theta} = \frac{-n}{\sum_{i=1}^n \ln y_i}$$

I am wondering what part of my answer is wrong. Could someone please help figure it out?
